﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Sql;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data;


namespace sccf
{
    public class GestionarUsuariosController
    {
        public static SqlDataReader buscar(string elemento, string tipo)
        {
            SqlDataReader result = GestionarUsuariosModel.ObtenerPersonas(elemento, tipo);
            return result;
        }
        public static void borrar(string id)
        {
            GestionarUsuariosModel.BorrarPersonas(id);
        }
        public static void Registrar(string login, string nombre, int tipo, string correo1, string correo2, string cargo, string pass)
        {
            GestionarUsuariosModel.Registrar(nombre, login, tipo, correo1, correo2, cargo, pass);
        }
        public static SqlDataReader BuscarTodos()
        {
            SqlDataReader reader = GestionarUsuariosModel.BuscarTodos();
            return reader;
        }
        public static SqlDataReader modificar(string id, string nombre, string cargo, string email, string email2)
        {
            SqlDataReader reader = GestionarUsuariosModel.ModificarPersona(id, nombre, cargo, email, email2);
            return reader;
        }

        internal static  DataTable buscarLDAP()
        {
            //List<List<string>> lista1 = new List<List<string>>();
            //List<Usuario> listaldapprof = ConexionLDAP.obtenerInfo("users");

            //List<Usuario> listaldap = listaldapprof;
            //DataTable dt = new DataTable();
            //dt.Columns.Add("Login", Type.GetType("System.String"));
            //dt.Columns.Add("Nombre", Type.GetType("System.String"));
            //dt.Columns.Add("Correo", Type.GetType("System.String"));
            //dt.Columns.Add("Correo 2", Type.GetType("System.String"));
            //dt.Columns.Add("Cargo", Type.GetType("System.String"));
            //dt.Columns.Add("Password", Type.GetType("System.String"));
            //foreach (Usuario user in listaldap)
            //{
            //    dt.Rows.Add();
            //    dt.Rows[dt.Rows.Count - 1]["Login"] = user.login;
            //    dt.Rows[dt.Rows.Count - 1]["Nombre"] = user.Nombre;
            //    dt.Rows[dt.Rows.Count - 1]["Correo"] = user.Correo;
            //    dt.Rows[dt.Rows.Count - 1]["Correo 2"] = user.Correo2;
            //    dt.Rows[dt.Rows.Count - 1]["Cargo"] = user.cargo;
            //    dt.Rows[dt.Rows.Count - 1]["Password"] = user.pass;
            //}


            string[,] arrMultiD = {

                    { "maestrada", "Maria Estrada", "maestrada@itcr.ac.cr", "mariaestrada.s@gmail.com","Profesor","pablo" },

                    { "relopez", "Rebeca López" ,"relopez@ic-itc.ac.cr", "conaloco24@gmail.com","Estudiante","pablo"},

                    { "nnavarro", "Norma Navarro" ,"Sydney", "Australia","Profesor","pablo"},

                    { "pflores", "Pablo Floes", "pflores@ic-itcr.ac.cr", "pablofg_1201@gmail.com","Estudiante","pablo"},
                    { "jstradi", "Jose Stradi", "Tokyo", "Japan","Pablo","pablo"},
                    { "Jake", "18", "Tokyo", "Japan","Pablo","pablo"},
                    { "Jake", "18", "Tokyo", "Japan","Pablo","pablo"},
                    { "Jake", "18", "Tokyo", "Japan","Pablo","pablo"},
                    { "Jake", "18", "Tokyo", "Japan","Pablo","pablo"},
                    { "Jake", "18", "Tokyo", "Japan","Pablo","pablo"},
                    { "Jake", "18", "Tokyo", "Japan","Pablo","pablo"},
                    { "Jake", "18", "Tokyo", "Japan","Pablo","pablo"},

                    { "Tom","34" , "Mumbai", "India","Pablo","pablo"}

                 };

            DataTable dt = new DataTable();

            dt.Columns.Add("Login", Type.GetType("System.String"));

            dt.Columns.Add("Nombre", Type.GetType("System.String"));

            dt.Columns.Add("Correo", Type.GetType("System.String"));

            dt.Columns.Add("Correo 2", Type.GetType("System.String"));

            dt.Columns.Add("Cargo", Type.GetType("System.String"));

            dt.Columns.Add("Password", Type.GetType("System.String"));
            for (int i = 0; i < arrMultiD.GetLength(0); i++)
            {

                dt.Rows.Add();

                dt.Rows[dt.Rows.Count - 1]["Login"] = arrMultiD[i, 0];

                dt.Rows[dt.Rows.Count - 1]["Nombre"] = arrMultiD[i, 1];

                dt.Rows[dt.Rows.Count - 1]["Correo"] = arrMultiD[i, 2];
                dt.Rows[dt.Rows.Count - 1]["Correo 2"] = arrMultiD[i, 3];

                dt.Rows[dt.Rows.Count - 1]["Cargo"] = arrMultiD[i, 4];
                dt.Rows[dt.Rows.Count - 1]["Password"] = arrMultiD[i, 5];

            }

            
            return dt;

        }
    }
}